package br.com.duduso.conferencia_claro_desktop.components;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.SwingWorker;

/**
 * Barra de Progresso Para Execução de Tarefas
 * @author duduso
 */
public abstract class BarraProgresso extends JFrame{

        public BarraProgresso() {

                this.setTitle("Por Favor Aguarde");
                this.setSize(300, 100);
                this.setVisible(true);
                this.setLocationRelativeTo(null);
                
                new SwingWorker() {
                        @Override
                        protected Object doInBackground() throws Exception {
                               executar();
                               done();
                               return null;
                        }
                        @Override
                        protected void done() {
                               super.done();
                               setVisible(false);
                        }
                }.execute();

                JProgressBar progressBar = new JProgressBar();
                progressBar.setIndeterminate(true);
                progressBar.setBorder(BorderFactory.createTitledBorder("Executando..."));

                this.getContentPane().add(progressBar);

        }

        public abstract void executar();

}
